#ifndef LIBRARY_LIBRARY_H_
#define LIBRARY_LIBRARY_H_

#include <QObject>
#include <QVector>
#include <QMutex>
#include <QSharedPointer>

class Library : public QObject {
private:
    Q_OBJECT
    QVector<QSharedPointer<QMutex> > books;
    mutable QMutex libMutex;
    volatile size_t maxBooks, readInterval, writeInterval;
    mutable size_t waitingWorkers;
public:
    Library();
    int add();
    size_t getLibSize();
    QSharedPointer<QMutex> getBook(size_t index);
    void returnBook(QSharedPointer<QMutex> book);
    size_t getReaderInterval();
    size_t getWriterInterval();
    bool isFull();
public slots:
    void updateMaxBooks(int newValue);
    void setReaderInterval(int newValue);
    void setWriterInterval(int newValue);

signals:
    void numberOfBooksChanged(int value);
    void awaitingUpdate(int value);

};

#endif // LIBRARY_LIBRARY_H_
